<?php
	echo $this -> Html -> script(array('msubcategory.js'));
?>
<div id="mainContent">
<?php
	echo $this -> Form -> create('Subcategory', array('id' => 'frmMain', 'url' => 'update', 'data-ajax' => 'false'));
?>
    <!--  start content-table-inner -->
	<div id="content-table-inner">
        <p>
        	<input type="button" value="Thêm nhóm con mới" onclick="location.href='<?php echo $this -> Html -> url('/',true).'msubcategory/insert?id='.$categoryId?>'" />
        	<?php 
        	if($categoryId != null) {
	        	echo "<input type='button' id='btnChangeOrder' value='Sắp xếp nhóm con' onclick='ChangeOrderTop()' />";
	        }
	        ?>        	
        </p>
        <br />
        <table id="product-table" border="0" width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <th><a>Tên nhóm</a></th>
                <th><a>Mô tả</a></th>
                <th><a>Thứ tự</a></th>
                <th><a>Nhóm cha</a></th>
                <th><a>Trạng thái</a></th>
                <th>&nbsp</th>
            </tr>
            <?php 
	            foreach ($subCategoryList as $subCategory) {
	                echo "<tr>";
	                    echo "<td>".$subCategory['Viewsubcategory']['subcatename']."</td>";
	                    echo "<td>".$subCategory['Viewsubcategory']['subcatedescription']."</td>";
	                    echo "<td><input type='text' class='toporderindex' value=".$subCategory['Viewsubcategory']['subcatetoporder']." itemId=".$subCategory['Viewsubcategory']['subcateid']." readonly='true' /></td>";
	                    echo "<td>".$subCategory['Viewsubcategory']['catename']."</td>";
	                    if($subCategory['Viewsubcategory']['subcatestatus'] == '1') {
	                    	echo "<td>Bật</td>";
	                    } else {
	                    	echo "<td>Tắt</td>";
	                    }
	                    echo "<td>";
	                        echo "<input type='button' value='Sửa' onclick='Update(".$subCategory['Viewsubcategory']['subcateid'].")' />";
	                        echo " <input type='button' value='Xóa' onclick='Delete(".$subCategory['Viewsubcategory']['subcateid'].")' />";
	                    echo "</td>";
                	echo "</tr>";
            	}
            ?>
        </table>
        <?php echo $this -> Form -> input('categoryId', array('label' => '', 'type' => 'hidden', 'value' => $categoryId, 'name' => 'categoryId', 'id' => 'categoryId')); ?>
        <br />
        <br />
        <p><a href="JavaScript:history.back()">Quay lại</a></p>
    </div>
<?php echo $this -> Form -> end(); ?>
</div>